home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / math / gle-3.000 / gle-3 / gle / d_p79.c < prev    next >
C/C++ Source or Header  |  1995-02-07  |  8KB  |  327 lines

  1. /*--------------------------------------------------------------*/
  2. /*      DSIR P79 Driver 1.0 , for GLE V3.0                      */
  3. /*--------------------------------------------------------------*/
  4. #include "all.h"
  5. #include <math.h>
  6. #include "core.h"
  7. #include "mygraph.h"
  8. #include "mydev.h"
  9. #include <descrip.h>
  10. #define GS 29
  11. #define FF 12
  12. #define MAXX (400L*38L)
  13. #define MAXY (400L*25L)
  14. int ingraphmode;
  15. extern struct gmodel g;
  16. /*---------------------------------------------------------------------------*/
  17. #define pi 3.141592653
  18. #define true (!false)
  19. #define BLACKANDWHITE 1
  20. #define ESC 27
  21. #define false 0
  22. #define dbg if ((gle_debug & 64)>0)
  23. #define stop if ((gle_debug & 128)>0) return
  24. extern int gle_debug;
  25. int incap=true;
  26. int getch(void);
  27. /*---------------------------------------------------------------------------*/
  28. /* The global variables for the PC screen driver */
  29. /*-----------------------------------------------*/
  30.  
  31. int i,l,j,ix,iy;
  32. double f;
  33. double devxcm,devycm;  /* settable via environment variables (or symbols*/
  34. FILE *hpfile;
  35.  
  36. #define gerr() i = graphresult(); if (i!=0) printf("Graph error: %s \n",grapherrormsg(i));
  37.  
  38. double d_scale, d_xscale, d_yscale;
  39. int d_graphmode;
  40. int d_fillstyle=1,d_fillcolor;
  41. int d_lstyle,d_lwidth;
  42. char outstr[400];
  43.  
  44. d_devcmd(char *s)
  45. {}
  46. /*---------------------------------------------------------------------------*/
  47. d_dfont(char *c)
  48. {
  49.     /* only used for the DFONT driver which builds fonts */
  50. }
  51. /*---------------------------------------------------------------------------*/
  52. static char lastline[80];
  53. d_message(char *s)
  54. {
  55.     static int single_step;
  56.     int oldcolor,oldx,oldy;
  57.     printf("%s\n",s);
  58. }
  59. /*---------------------------------------------------------------------------*/
  60. d_source(char *s)
  61. {
  62.     s=s;
  63. }
  64. /*---------------------------------------------------------------------------*/
  65. d_get_type(char *t)
  66. {
  67.     strcpy(t,"HARDCOPY, P79, VAX");
  68. }
  69. /*---------------------------------------------------------------------------*/
  70. d_set_path(int onoff)
  71. {}
  72. /*---------------------------------------------------------------------------*/
  73. d_newpath()
  74. {
  75. }
  76. /*---------------------------------------------------------------------------*/
  77. extern int pl2ca;
  78. float tworld[4][4];
  79. d_open(double width, double height)
  80. {
  81.     float sx,sy,xstret,ystret,ss;
  82.  
  83.     PLT00();
  84.     MATUN(&tworld[0][0]);
  85.     SETWM(&tworld[0][0]);
  86.     setpn(&1);
  87.     sx = width;
  88.     sy = height;
  89.     xstret = 1;
  90.     ystret = 1;
  91.     if (sx<sy) xstret = sx/sy;
  92.     if (sy<sx) ystret = sy/sx;
  93.     SETDS2(&xstret,&ystret);
  94.     ss = sx;
  95.     if (sy>sx) ss = sy;
  96.     SETSZ(&ss); /* SET SIZE */
  97.     SETVP2(&0.0,&xstret,&0.0,&ystret);
  98.     SETWW(&0.0,&sx,&0.0,&sy);
  99.     plotter_fonts();
  100. }
  101. /*---------------------------------------------------------------------------*/
  102. d_tidyup()
  103. {
  104.     d_close();
  105. }
  106. d_close()
  107. {
  108.     int a,stat;
  109.     static $DESCRIPTOR(flse,"FALSE");
  110.     g_flush();
  111.     a = 18;
  112.     SETDRV(&a,&flse,&stat);
  113.     if ((stat&1)!=1) gprint("p79 status %d\n",stat);
  114.     SETEJ();
  115. }
  116. /*---------------------------------------------------------------------------*/
  117. d_set_line_cap(int i)
  118. {
  119.     i++;
  120. }
  121. /*---------------------------------------------------------------------------*/
  122. d_set_line_join(int i)
  123. {
  124.     i++;
  125. }
  126. /*---------------------------------------------------------------------------*/
  127. d_set_line_miterlimit(double d)
  128. {
  129.     i++;
  130. }
  131. /*---------------------------------------------------------------------------*/
  132. d_set_line_width(double w)
  133. {
  134. }
  135. /*---------------------------------------------------------------------------*/
  136. d_set_line_styled(double dd)
  137. {}
  138. d_set_line_style(char *s)
  139. {
  140.     d_lstyle = 2;
  141.     if (strcmp(s,"")==0) d_lstyle = 1;
  142.     if (strcmp(s,"1")==0) d_lstyle = 1;
  143. }
  144. /*---------------------------------------------------------------------------*/
  145. d_fill()
  146. {
  147. }
  148. /*---------------------------------------------------------------------------*/
  149. d_fill_ary(int nwk,double (*wkx)[],double (*wky)[])
  150. {
  151.     int i;
  152. /*      fprintf(psfile,"%g %g moveto \n",(*wkx)[0],(*wky)[0]);
  153.     for (i=1;i<nwk;i++)
  154.         fprintf(psfile,"%g %g l \n",(*wkx)[i],(*wky)[i]);
  155. */
  156. }
  157. d_line_ary(int nwk,double (*wkx)[],double (*wky)[])
  158. {
  159.     int i;
  160. /*
  161.     g_dev( (*wkx)[0], (*wky)[0], &ix, &iy);
  162.     moveto(ix,iy);
  163.     for (i=1;i<nwk;i++) {
  164.         g_dev( (*wkx)[i], (*wky)[i], &ix, &iy);
  165.         lineto(ix,iy);
  166.     }
  167. */
  168. }
  169. /*---------------------------------------------------------------------------*/
  170. d_stroke()
  171. {
  172. }
  173. /*---------------------------------------------------------------------------*/
  174. d_clip()
  175. {
  176. }
  177. /*---------------------------------------------------------------------------*/
  178. d_set_matrix(double newmat[3][3])
  179. {
  180. }
  181. /*---------------------------------------------------------------------------*/
  182. d_move(double zx,double zy)
  183. {
  184. }
  185. /*---------------------------------------------------------------------------*/
  186. d_reverse()     /* reverse the order of stuff in the current path */
  187. {
  188. }
  189. /*---------------------------------------------------------------------------*/
  190. d_closepath()
  191. {
  192.     g_line(g.closex,g.closey);
  193. }
  194. /*---------------------------------------------------------------------------*/
  195. int hpglxy(double xx, double yy);
  196. d_line(double zx,double zy)
  197. {
  198.     static double ix,iy,ux,uy;
  199.     float x,y;
  200.     char s1[40],s2[40];
  201.     if (g.xinline==false) {
  202.         g_dev(g.curx,g.cury,&ux,&uy);
  203.         x = ux; y = uy;
  204.         MOVA2(&x,&y);
  205.     }
  206.     g_dev(zx,zy,&ux,&uy);
  207.     x = ux; y = uy;
  208.     LINA2(&x,&y);
  209. }
  210. /*---------------------------------------------------------------------------*/
  211. d_clear()
  212. {
  213.  }
  214. /*---------------------------------------------------------------------------*/
  215. d_flush()
  216. {
  217. }
  218. /*---------------------------------------------------------------------------*/
  219. d_arcto(dbl x1,dbl y1,dbl x2,dbl y2,dbl rrr)
  220. {
  221.     df_arcto(x1,y1,x2,y2,rrr);
  222. }
  223. /*---------------------------------------------------------------------------*/
  224. d_arc(dbl r,dbl t1,dbl t2,dbl cx,dbl cy)
  225. {
  226.     df_arc(r,t1,t2,cx,cy);
  227. }
  228. /*---------------------------------------------------------------------------*/
  229. d_narc(dbl r,dbl t1,dbl t2,dbl cx,dbl cy)
  230. {
  231.     /*swap t1 t2*/
  232.     df_arc(r,t2,t1,cx,cy);
  233. }
  234. /*---------------------------------------------------------------------------*/
  235. d_box_fill(dbl x1, dbl y1, dbl x2, dbl y2)
  236. {
  237.     df_box_fill(x1,y1,x2,y2);
  238. }
  239. d_box_stroke(dbl x1, dbl y1, dbl x2, dbl y2)
  240. {
  241.     df_box_stroke(x1,y1,x2,y2);
  242. }
  243. /*---------------------------------------------------------------------------*/
  244. d_circle_stroke(double zr)
  245. {
  246.     df_circle_stroke(zr);
  247. }
  248. d_circle_fill(double zr)
  249. {
  250.     df_circle_fill(zr);
  251. }
  252. /*---------------------------------------------------------------------------*/
  253. d_bezier(dbl x1,dbl y1,dbl x2,dbl y2,dbl x3,dbl y3)
  254. {
  255.     double ax,bx,cx,ay,by,cy,dist;
  256.     double xxx,yyy,i,t,nstep,x0,y0;
  257.     g_get_xy(&x0,&y0);
  258.     dist = fabs(x3-x0) + fabs(y3-y0);
  259.     nstep = 10;
  260.     if (dist>3) nstep = 20;
  261.     if (dist<.5) nstep = 5;
  262.     if (dist<.3) nstep = 3;
  263.     if (dist<.1) {
  264.         g_line(x3,y3);
  265.         return;
  266.     }
  267.     cx = (x1-x0)*3;
  268.     bx = (x2-x1)*3-cx;
  269.     ax = x3-x0-cx-bx;
  270.     cy = (y1-y0)*3;
  271.     by = (y2-y1)*3-cy;
  272.     ay = y3-y0-cy-by;
  273.     for (i=0;i<=nstep;i++) {
  274.         t = i/nstep;
  275.         xxx = ax*pow(t,3.0) + bx*t*t + cx*t + x0;
  276.         yyy = ay*pow(t,3.0) + by*t*t + cy*t + y0;
  277.         g_line(xxx,yyy);
  278.     }
  279. }
  280. /*---------------------------------------------------------------------------*/
  281. d_set_color(int32 f)
  282. {
  283.     int i;
  284.     char ss[50];
  285.     colortyp  cc;
  286.     cc.l = f;
  287.     i = 1;
  288.     if (cc.b[B_R]>100) i = 2;
  289.     if (cc.b[B_G]>100) i = 3;
  290.     if (cc.b[B_B]>100) i = 4;
  291.     if (cc.b[B_B]>100 && cc.b[B_G]>100) i = 5;
  292.     if (cc.b[B_R]>250 && cc.b[B_G]>250 && cc.b[B_B]>250) i = 6;
  293. }
  294. d_set_fill(int32 f)
  295. {
  296. }
  297. /*---------------------------------------------------------------------------*/
  298. d_beginclip()
  299. {
  300. }
  301. d_endclip()
  302. {
  303. }
  304. struct char_data {float wx,wy,x1,y1,x2,y2; };
  305. int font_get_chardata(struct char_data **cd, int ff, int cc);
  306. /*---------------------------------------------------------------------------*/
  307. d_char(int font, int cc)
  308. {
  309.     static struct char_data cd;
  310.     static int ix,iy,ix1,ix2,iy1,iy2,fz,fzx;
  311.     static int ux,uy;
  312.     static int safnt;
  313.     char ss[2];
  314.  
  315.     ss[0] = cc;
  316.     ss[1] = 0;
  317.     if (safnt==0) safnt = pass_font("PLSR");
  318.     if (font>=2) {
  319.         my_char(font,cc);
  320.         return;
  321.     }
  322.     my_char(safnt,cc);
  323. }
  324.  
  325.  
  326.  
  327.